<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>日志管理</title>
<%@include file="/WEB-INF/views/include/head.jsp" %>
	<script type="text/javascript">
		$(document).ready(function() {
			initGrid();//初始化表格		 
		});

	    /*初始化表格*/
	    function initGrid(){
	    	$("#jqGrid").jqGrid({
                url: '${ctxAdmin}/sys/log/loadData',
                mtype: "POST",
                datatype: "json",
                responsive:true,
                page: 1,
                colModel: [       			
					{ label: 'id', name: 'id', key: true, hidden:true}, 
                    { label: '操作用户',name: 'createUserName',width: 100,align:'center'},
                    { label: '所在部门', name: 'createUserOfficeName',width:100,align:'center'},
                    { label: '操作标题', name: 'title',width: 250,align:'center'}, 
                    { label: '操作IP', name: 'remoteAddr', width: 90,align:'center' },
                    { label: '操作时间', name: 'createDate', width: 120,align:'center' },
                    {label:'操作',name:'cz',search:false,sortable:false,title:false,formatter:czFmt,width:50,align:'center'}
                ],
				viewrecords: true,
                height: height,
                rowNum: 10,
                rowList:[10,20,30],
                loadonce:false,
                multiselect: false,
                autowidth: true,
                multiselect: true,
                pager: "#jqGridPager"
            });
			$('#jqGrid').jqGrid('navGrid','#jqGridPager',{edit:false,add:false,del:false,search:false});
	    }
	    /*格式化操作栏*/
	    function czFmt(c,o,r){
			var res='';
			var id=r.id;
			var description=r.description;
			res+='<shiro:hasPermission name="sys:log:edit">';
			res+='<a class="btn-danger btn-sm" href="javascript:void(0)" onclick="deleteData(\''+id+'\')">删除</a>&nbsp;&nbsp;';
			res+='</shiro:hasPermission>';
			return res;
		}
	
		function deleteData(id){
			confirmx('你确定要删除此数据吗？',null,function(){
					$.ajax({
					url:'${ctxAdmin}/sys/log/delete',
					type:'post',
					dataType:'json',
					data:{id:id},
					success:function(res){
					var code = res.code;
					var message = res.message;				
					layer.msg(message);
					$('#jqGrid').trigger("reloadGrid");
					}
				});}		
			);			
		}

		function deleteDataBatch(ids){
		
		var _ids=$('#jqGrid').jqGrid('getGridParam','selarrrow');
		if(_ids.length==0){
		layer.msg("请选择要操作的行！");
		return
		}
		var ids = _ids.join(",");
		
		confirmx('要删除选中的项吗？',null,function(){			
				$.ajax({
					url:'${ctxAdmin}/sys/log/delete',
					type:'post',
					dataType:'json',
					data:{id:ids},
					success:function(res){
					var code = res.code;
					var message = res.message;				
					layer.msg(message);
					$('#jqGrid').trigger("reloadGrid");
					}
				});				
				}		
			);									
			
		}
		
				
		$(function() {
			$('#btnSubmit').click(function() {
				var title = $("#title").val();
				var beginDate = $("#beginDate").val();
				var endDate = $("#endDate").val();
			
				$('#jqGrid').jqGrid('setGridParam', {
					datatype : 'json',
					postData : {
						'title' : title,
						'beginDate' : beginDate,
						'endDate':endDate
					}
				}).trigger("reloadGrid");
			});

		});
	</script>

</head>
<body>

	<div class="jqGrid_wrapper">
	
		<div class="search_row">
		
			<label class="col-sm-1">日期范围：</label>
			<div class="col-sm-2">
				<input id="beginDate" name="beginDate"
					type="text" readonly="readonly" 
					class="form-control Wdate "
					value="<fmt:formatDate value="${log.beginDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" />
			</div>
			<label class="col-sm-1" style="width: 20px;">--</label>
			<div class="col-sm-2" style="height: 30px;">
				<input id="endDate" name="endDate" type="text" readonly="readonly"
					 class="form-control Wdate"
					value="<fmt:formatDate value="${log.endDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" />&nbsp;&nbsp;
			</div>
			
			
			<label class="col-sm-1">操作标题：</label>
			<div class="col-sm-2">
			<input id="title" name="title" type="text" class="form-control ipt-search"/>
			</div>
						
			<div class="col-sm-search">
			&nbsp;&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-sm btn-success" type="button"  value="查询" />
			&nbsp;&nbsp; <input id="btnReset" class="btn btn-sm btn-danger" type="button" value="重 置" />
			<shiro:hasPermission name="sys:log:edit">
			&nbsp;&nbsp; <input id="btnDelete" class="btn btn-sm btn-danger" type="button" onclick="deleteDataBatch()" value="批量删除" />
			</shiro:hasPermission>
			
			
			</div>			
		</div>
		<div class="search_row_split"></div>
		<table id="jqGrid"></table>
		<div id="jqGridPager"></div>
	</div>
				
</body>
</html>